from flask import Flask
from flask_cors import CORS
from flask_migrate import Migrate
from settings import Config
from db_init import db
from swaager_init import siwa
from tools.login_init import login
from flask_socketio import SocketIO


def create_flask():
    # app = Flask(__name__, static_url_path='/sadfsadfasdf')
    app = Flask(__name__)
    socket = SocketIO(app, cors_allowed_origins="*",
                      async_mode='eventlet')
    login.init_app(app)
    app.config.from_object(Config)
    app.secret_key = 'syl'
    migrate = Migrate()
    CORS(app)
    db.init_app(app=app)
    migrate.init_app(app, db)
    siwa.init_app(app)

    return app, socket
